package com.baidu.lib_home.adapter

import androidx.recyclerview.widget.RecyclerView
import com.baidu.lib_audio.AudioController
import com.baidu.lib_common.base.BaseRecyclerViewAdapter
import com.baidu.lib_common.constant.AudioChangeEvent
import com.baidu.lib_common.utils.loadurl
import com.baidu.lib_home.databinding.MusicItemBinding
import com.baidu.lib_leancloud.db.FavoriteViewModel
import com.baidu.lib_leancloud.db.RoomHelper
import com.baidu.lib_leancloud.model.Music
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode

class PersonalMusicAdapter: BaseRecyclerViewAdapter<MusicItemBinding,Music>() {
    override fun bindData(binding: MusicItemBinding, data: Music) {
        binding.musicImage.loadurl(data.image)
        binding.musicName.text = data.name
        binding.singer.text = data.singer
        binding.root.setOnClickListener{
            AudioController.instance.changePlayMode(false,false)
            EventBus.getDefault().post(AudioChangeEvent(data,getDataList()))
        }
        binding.love.setImageResource(0)


    }
}